#******************************************************************************
# Copyright (C) 2016  671643387@qq.com
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#****************************************************************************/
cmake_minimum_required(VERSION 2.6)

project(node)
set(node_VERSION 0.0.1)

option(wno_deprecated "Wno-deprecated-declarations" ON)
if (UNIX)
    add_definitions(-Wall)
    if (wno_deprecated)
    	add_definitions(-Wno-deprecated-declarations)
    endif()
    if (CMAKE_COMPILER_IS_GNUCXX)
        add_definitions(-std=gnu++0x)
    else ()
        add_definitions(-std=stdc++11)
    endif()
elseif(WIN32)
    add_definitions(-W3)
endif()

include(cmake/CheckSystemPlatform.cmake)
include(cmake/CheckSystemArch.cmake)
include(cmake/CheckSystemEndian.cmake)
CHECK_SYSTEM_PLATFORM(SYSTEM_PLATFORM)
CHECK_SYSTEM_ARCH(SYSTEM_ARCH)
CHECK_SYSTEM_ENDIAN(SYSTEM_ENDIAN)
configure_file(config.h.in ${PROJECT_SOURCE_DIR}/node/config.h)

if (UNIX)
	set(SRCPLAT POSIX)
elseif(WIN32)
    set(SRCPLAT WIN32)
endif()

include_directories(
	${PROJECT_SOURCE_DIR}
)
set(node_base_SRC
	node/platform.h
	node/noncopyable.h
)
set(node_system_SRC
	node/system/mutex.h
	node/system/mutex_${SRCPLAT}.h
	node/system/event.h
	node/system/event_${SRCPLAT}.h
	node/system/runnable.h
	node/system/thread.h
	node/system/thread_${SRCPLAT}.h

	src/system/mutex.cpp
	src/system/mutex_${SRCPLAT}.cpp
	src/system/event.cpp
	src/system/event_${SRCPLAT}.cpp
	src/system/thread.cpp
	src/system/thread_${SRCPLAT}.cpp
)
set(node_util_SRC
	node/util/option.h
    node/util/option_set.h
    node/util/application.h

	src/util/option.cpp
    src/util/option_set.cpp
    src/util/application.cpp)
set(node_SRC
	${node_base_SRC}
	${node_system_SRC}
	${node_util_SRC}
)
if (WIN32 AND MSVC)
    source_group(base FILES ${node_base_SRC})
    source_group(system FILES ${node_system_SRC})
    source_group(util FILES ${node_util_SRC})
endif()
add_library(node STATIC ${node_SRC})